define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'zjdangkou/index' + location.search,
                    add_url: 'zjdangkou/add',
                    edit_url: 'zjdangkou/edit',
                    del_url: 'zjdangkou/del',
                    multi_url: 'zjdangkou/multi',
                    import_url: 'zjdangkou/import',
                    table: 'zjdangkou',
                }
            });

            var table = $("#table");
            $.fn.bootstrapTable.locales[Table.defaults.locale]['formatShowingRows'] = function (pageFrom, pageTo, totalRows) {
                return ' ';
            };
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                showToggle: false,
                showColumns: false,
                searchFormVisible: true,
                pageSize: 35,
                columns: [
                    [
                        {checkbox: true},
                        //{field: 'id', title: __('Id')},
                        {field: 'day', title: __('Day'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        //{field: 'day', title: __('Day'),  searchList: $.getJSON("ajax/monthselect")},
                        {field: 'shou', title: __('收入'), operate: false,cellStyle:function(){  return {css: {"color": "#c4ab0a"}}; }},
                        {field: 'zhi', title: __('支出'), operate: false ,cellStyle:function(){  return {css: {"color": "red"}}; }},
                        {field: 'jieyu', title: __('结余'), operate: false,cellStyle:function(){  return {css: {"color": "#009900"}}; }},
                        {field: 'duigong', title: __('对公户收入'), operate: false},
                        {field: 'ronghe', title: __('新装'), operate: false},
                        {field: 'anzhuang_fee', title: __('安装费'), operate: false},
                        {field: 'xufei', title: __('续费'), operate: false},
                        {field: 'banqian', title: __('复通搬迁'), operate: false},
                        {field: 'zhi_za', title: __('杂费支出'), operate: false},
                        {field: 'shou_za', title: __('杂费收入'), operate: false},
                        {field: 'ershou', title: __('二手房东宽带'), operate: false},
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
            Table.api.fixedheader(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
